<?php
/**
 * Extra NPC data.
 *
 * @author Mark Dohmen.
 */
final class NPCDefinition {
	
	/**
	 * Holds a set of definitions in an Array.
	 */
	private static $npcDefinitions;
	
	/**
	 * Add's a definition to the array.
	 *
	 * @param $npcDefinition
	 */
	final public static function addDefinition(NPCDefinition $npcDefinition) {
		self::$npcDefinitions[$npcDefinition->getId()] = $npcDefinition;
	}
	
	/**
	 * Gets an NPCDefinition by #id.
	 *
	 * @return $npcDefinition/null
	 */
	final public static function forId(int $id) {
		if (self::$npcDefinitions[$id] instanceof NPCDefinition) {
			return (object) self::$npcDefinitions[$id];
		}
		return NULL;
	}
	
	/**
 	 * The #ID of this NPC.
 	 */
	private $id;
	
	/**
	 * The NPC's name.
	 */
	private $name;
	
	/**
	 * The description
	 */
	private $description;
	
	/**
	 * It's max Health
	 */
	private $health;
	
	/**
	 * It's inventory (could be used for drops,
	 * or items that give him extra power).
	 */
	private $inventory;
	
	/**
	 * Class Constructor..
	 *
	 * @param $id
	 * @param $name
	 * @param $description
	 * @param $health
	 * @param $inventory
	 */
	final public function NPCDefinition(int $id, string $name, string $description, int $health, Inventory $inventory) {
		$this->name = $name;
		$this->description = $description;
		$this->health = $health;
		$this->inventory = $inventory;
	}
	
	/**
 	 * Gets the #id.
	 *
	 * @return $id
 	 */
	final public function getId() {
		return (int) $this->id;	
	}
	
	/**
	 * Gets the name.
	 *
	 * @return $name
	 */
	final public function getName() {
		return (string) $this->name;
	}
	
	/**
	 * Gets the description.
	 *
	 * @return $description
	 */
	final public function getDescription() {
		return (string) $this->description;
	}
	
	/**
	 * Gets the maximum health.
	 *
	 * @return $health
	 */
	final public function getHealth() {
		return (int) $this->health;
	}
	
	/**
	 * Gets the inventory.
	 *
	 * @return $inventory/null
	 */
	final public function getInventory() {
		if ($this->inventory instanceof Inventory) {
			return (object) $this->inventory;
		}
		return NULL;
	}
}
?>